Página 1

Columna 1

Tabla de datos

Columna 2

Total de alumnos por curso

Cuadro de texo con comentarios {data-height = 300}

  1. Se incluyen los datos de alumnos por curso
  2. Se analizan por carrera

Cuadro de texto sin título {data-height = 100, no-title}

Página 2

Row

Componente 1

Componente 2

---
title: "Alumnado UCM"
author: "M. Pérez de los Ríos"
date: "Mayo 2024"
output: 
  flexdashboard::flex_dashboard:
    theme: cosmo
    source_code: embed
    social: ["twitter", "facebook"]
---

```{r setup, include=FALSE}
library(flexdashboard)
library(readr)   
library(readxl)
library(ggplot2)
library(dplyr)
library(plotly)
library(DT)

df <- read_delim("~/Desktop/Proyecto_tema_3/datos_tratados.csv",  delim = ";", escape_double = FALSE)
    
df$CURSO <- factor(df$CURSO)
df$CENTRO <- factor(df$CENTRO)

#agrupamos los datos por curso

grouped_data <- df %>%
  group_by(CURSO) %>%
  summarise(across(where(is.numeric), sum))

df_4_M <- select(df,CURSO,CENTRO,TOTAL_MUJERES,PORC_MUJERES)
df_4_H <- select(df,CURSO,CENTRO,TOTAL_HOMBRES,PORC_HOMBRES)
colnames(df_4_M)[3] <-"TOTAL"
colnames(df_4_H)[3] <-"TOTAL"
colnames(df_4_M)[4] <-"PORCENTAJE"
colnames(df_4_H)[4] <-"PORCENTAJE"
nrow(df_4_H)
rep('Hombre', times = nrow(df_4_H))
nrow(df_4_M)
rep('Mujer', times = nrow(df_4_M))
df_4_M$SEXO <- rep('Mujer', times = nrow(df_4_M))
df_4_H$SEXO <- rep('Hombre', times =nrow(df_4_H))
df_5 <- bind_rows(df_4_M,df_4_H)
df_3 <- filter(df, CENTRO == "DERECHO" | CENTRO == "CIENCIAS_DE_LA_INFORMACION")

df_3$CURSO <- factor(df_3$CURSO)
df_3$CENTRO <- factor(df_3$CENTRO)
```

# Página 1
## Columna 1
### Tabla de datos

```{r}
# Crear una tabla interactiva con DT
tabla_interactiva <- datatable(df, options = list( pageLength = 25))
tabla_interactiva

```

## Columna 2
### Total de alumnos por curso


```{r fig.width=10, fig.height=5}
ggplot(df, aes(x = CURSO, y = TOTAL)) +
  geom_col() +
  labs(title = "U.C.M", x = "Curso", y = "Total de alumnos/as",) +
  theme(axis.text.x = element_text(angle = 30, vjust = 1, hjust = 1, size = 8))
```


### Cuadro de texo con comentarios {data-height = 300}

1. Se incluyen los datos de alumnos por curso
2. Se analizan por carrera

### Cuadro de texto sin título {data-height = 100, no-title}

# Página 2 {data-orientation=rows}

## Row

### Componente 1

```{r fig.width=10, fig.height=5}
gl <- ggplot(df_5, aes(x = CURSO, w = TOTAL, fill = SEXO)) +
  geom_bar(aes(stat = "identity", position = "dodge")) +
  labs(title = "Total de Alumnos", x = "CURSO", y = "TOTAL") +
  scale_fill_manual(values = c("TOTAL_MUJERES" = "blue", "TOTAL_HOMBRES" = "red")) +
  theme(axis.text.x = element_text(angle = 30, vjust = 1, hjust = 1, size = 8))
g2 <- ggplotly(gl)
g2
````

### Componente 2

```{r fig.width=10, fig.height=5}
ggplot(df_3, aes(x=CENTRO, y=TOTAL)) +
  geom_boxplot( ) + 
  geom_jitter(aes(color = CENTRO )) +
  labs(title = "Distribución de los alumnos que estudian en la UCM",
       subtitle = "Gráficos de cajas, (geom_boxplot)",
       x = " ",
       y = "Número de matriculas por año \n"
  )
````